package org.dftproject.genesis.core.tasks;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class VolatileTaskRepository implements ITaskRepository {

	private final Map<String, ITask> taskById = Collections.synchronizedMap(new HashMap<String, ITask>());
	
	public Set<ITask> getTasks() {
		return new HashSet<ITask>(taskById.values());
	}

	public void addTask(ITask task) {
		taskById.put(task.getId(), task);
	}
	
	public void updateTask(ITask task) {
		taskById.put(task.getId(), task);
	}

	public ITask getTask(String id) {
		return taskById.get(id);
	}

	public void removeTask(ITask task) {
		taskById.remove(task.getId());
	}

}
